package edu.usm.cs.roberge;

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

/**
 * Basic application to verify web service client works correctly
 */
public class Application {

	public static void main(String[] args) throws ServiceException, RemoteException {
		CourseSchedulerServiceLocator locator = new CourseSchedulerServiceLocator();
		CourseScheduler sche = locator.getCourseSchedulerPort();
		
		Student dave = new Student();
		dave.setName("David");
		Integer id = sche.registerStudent(dave);
		dave.setId(id);
		System.out.println("Created a new student");
		
		Course course = new Course();
		course.setCourseName("Advanced Web Architectures");
		id = sche.registerCourse(course);
		System.out.println("Registered new course Advanced Web Architecture");
		
		Boolean b = sche.enrollStudentInCourse(dave.getId(), course.getId());
		if (!b) {
			System.err.println("Unable to register student");
			System.exit(0);
		}
		System.out.println("Registered Student in course");
		
		Student dave2 = sche.findStudent(dave.getId());
		System.out.println("Retrieved registered student");
	}
}
